from PyQt5.Qt import *
import sys



class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("表单布局")
        self.resize(600,400)
        name_lable = QLabel('姓名：')
        name_line = QLineEdit()

        age_lable = QLabel('年龄：')
        age_line = QSpinBox()

        tel_lable = QLabel('号码：')
        tel_line = QLineEdit()

        sex_lable = QLabel('性别：')

        check_btn = QFormLayout()
        man_btn=QRadioButton('男')
        woman_btn = QRadioButton('女')
        check_btn.addRow(man_btn,woman_btn)

        sub_btn = QPushButton('提交')


        form = QFormLayout()
        self.setLayout(form)
        form.addRow(name_lable,name_line)
        form.addRow(age_lable, age_line)
        form.addRow(tel_lable, tel_line)
        form.addRow(sex_lable, check_btn)
        form.addRow(sub_btn)

        form.setHorizontalSpacing(10)
        form.setVerticalSpacing(20)




if __name__=='__main__':
    app = QApplication(sys.argv)
    w = Window()
    w.show()
    sys.exit(app.exec_())